<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>双向绑定</title>
    <script src="angularjs/angular.min.js"></script>
</head>
<body ng-app="doraApp">

    <div ng-controller="ctrl">
        <input ng-model="title"/><br/>
        <textarea name="" id="" cols="30" rows="10" ng-model="body"></textarea><br/>
        <button ng-click="add()">add</button>
        <ul>
            <li ng-repeat="post in posts">
                <h3>{{post.title}}</h3>
                <p>{{post.body}}</p>
            </li>
        </ul>
    </div>
    <script>

        angular.module("doraApp",[])
                .controller("ctrl", function ($scope) {
                    $scope.posts = [];
                    $scope.add = function () {
                        $scope.posts.push({title:$scope.title,body:$scope.body});

                        $scope.title = "";
                        $scope.body = "";
                    }
                })
    </script>
</body>
</html>